package org.primefaces.examples.moviecollector.dao;


import static org.junit.Assert.*;

import java.util.List;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.primefaces.examples.moviecollector.domain.Calificacion;
import org.primefaces.examples.moviecollector.domain.Eventos;
import org.primefaces.examples.moviecollector.domain.Usuarios;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;




@RunWith(SpringJUnit4ClassRunner.class)
@Transactional
@TransactionConfiguration(transactionManager = "txManager")
@ContextConfiguration(locations = { "/applicationContext.xml" })


public class CalificacionDAOWithJPATest {
	
private CalificacionDAO califDAO;
	
	@Autowired
	public void setRepository(CalificacionDAO califDAO){
		this.califDAO=califDAO;
	}
	
	@Test
	public void guardarCalificacion(){
		Calificacion calif = new Calificacion();
		calif.setCalificacion("5");
		
		califDAO.persist(calif);
		assertNotNull(calif.getId());
	}
	

	@Test
	public void eliminar(){
	
		Calificacion calif = new Calificacion();
		calif.setCalificacion("3");
	
		califDAO.persist(calif);
		
		califDAO.delete(calif);
		
		
		assertFalse((!calif.getCalificacion().equals("3")));
		
		
	}
}

